package day52.basic.commonenum;

/** 系统错误码 **/
public enum ErrorCode {

    SYSTEM_ERROR("1001","系统内部异常!"),
    PAGE_ERROR("1002","分页错误!"),
    PASSWORD_REPEAT("1003","手机号格式异常!"),
    SHOP_EXISTS("1004","店铺已存在!"),
    EMP_SHOP_EXISTS("1005","已注册过店铺！"),
    CONTENT_AUDIT_FAILED("1006","内容审核失败！"),
    PICTURE_VERIFY_ERROR("1007","图片验证错误！"),
    IMAGECODE_TIME_OUT("1008","图片验证码已过期!"),
    IMAGECODE_ERROR("1009","图片验证码错误!"),
    PHONE_REPEAT("1010","该手机号已注册！"),
    PASSWORDS_INCONSISTENT("1011","两次密码不一致！"),
    SMSCODE_TIME_OUT("1012","短信验证码已过期!"),
    SMSCODE_ERROR("1013","短信验证码错误!"),
    ACCOUNT_NOT_FOUND("1014","该账户不存在！"),
    PASSWORD_ERROR("1015","密码错误！"),
    WECHAT_ERROR("1016","微信服务异常！"),
    ORDER_EXISTS("1017","此订单正在进行中!"),
    ORDER_FINISH("1018","此订单正已完成!");







    //错误码
    private String code;
    //错误信息
    private String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }
    public String getMessage() {
        return message+"["+code+"]";
    }

    public static ErrorCode getByCode(String code){
        //获取ErrorCode中所有对象的数组
        ErrorCode[] errorCodes = ErrorCode.values();

        for (ErrorCode errorCode : errorCodes) {
            if(errorCode.getCode().equals(code)){
                return errorCode;
            }
        }
        return null;
    }
}